<template>
  <div>
    招聘信息详情

    <el-descriptions title="公司信息" :column="1">
      <el-descriptions-item label="公司名字">{{
        recruit.cname
      }}</el-descriptions-item>
      <el-descriptions-item label="公司地址">{{
        recruit.address
      }}</el-descriptions-item>
    </el-descriptions>
    <el-descriptions title="招聘信息" :column="1">
      <el-descriptions-item label="招聘岗位">{{
        recruit.post
      }}</el-descriptions-item>
      <el-descriptions-item label="招聘人数">
        {{ recruit.number }}人</el-descriptions-item
      >
      <el-descriptions-item label="专业要求">{{
        recruit.major
      }}</el-descriptions-item>
      <el-descriptions-item label="发布时间">{{
        recruit.reTime
      }}</el-descriptions-item>
      <el-descriptions-item label="工作内容">{{
        recruit.content
      }}</el-descriptions-item>
    </el-descriptions>

    <el-button type="primary" @click="onSubmit">申请岗位</el-button>
    <el-button @click="unSubmit">返回</el-button>
  </div>
</template>

<script>
export default {
  name: "Home",
  data() {
    return {
      recruit: {},
    };
  },
  mounted() {
    const id = this.$route.query.id;
    this.page(id);
  },
  methods: {
    onSubmit() {
      const _this = this;
      const uid = this.$store.getters.getStudent.id;
      const rid = this.$route.query.id;
      if (uid != null) {
        _this.$axios.get("/addDelivery/" + uid + "/" + rid).then((res) => {
          // console.log(res.data.msg);

          if (res.data.msg == "操作成功") {
            _this
              .$alert("操作成功", "提示", {
                confirmButtonText: "确定",
              })
              .then(() => {
                location.reload();
              });
          } else {
            _this.$alert("你已申请该岗位，请勿重复申请！", "提示", {
              confirmButtonText: "确定",
            });
          }
        });
      } else {
        this.$confirm("你还未登录, 去登录?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.$router.push("/");
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消",
            });
          });
      }
    },
    unSubmit() {
      this.$router.push("/user/recruit");
    },
    page(id) {
      const _this = this;
      _this.$axios.get("/recruitAll/" + id).then((res) => {
        // console.log(res);
        _this.recruit = res.data.data;
      });
    },
  },
};
</script>

<style scoped>
</style>
